<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
    <#include "/common/elibs.html">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
</head>
<script>var index;
</script><body>
<div class="x-body">
    <form class="layui-form">
        <input type="hidden" name="idxProAdmin" id="idxProAdmin" value="${id}"/>
        <input type="hidden" name="idProPowerSupplyScheme" id="idProPowerSupplyScheme" value="${subsetId}"/>
        <input type="hidden" name="paramsType" id="paramsType" value="${type}"/>

        <div class="layui-form-item">
            <label class="layui-form-label">
                开始时间
            </label>
            <div class="layui-input-inline">
                <input type="text" id="beginTime" name="beginTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                结束时间
            </label>
            <div class="layui-input-inline">
                <input type="text" id="endTime" name="endTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item" id="difference">
            <label class="layui-form-label">
                距离结束时间天数
            </label>
            <div class="layui-input-inline">
                <input type="text" id="differenceTime" name="differenceTime"
                       autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
            </div>
        </div>

        <div class="layui-form-item" id="meteringList" style="padding: 20px; background-color: #F2F2F2;">

        </div>




        <div class="layui-form-item">
            <label for="" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" type=button codeTyle="3" lay-submit="">
                提交
            </button>
        </div>
    </form>
</div>
<script>
    var countDigit = 1;

    function powerSupply(){
        var html = '  <div class="layui-col-md6 powerSupply" style="width: 100%;"> \n' +
            '   <div class="layui-card"> \n' +
            '    <div class="layui-card-header">\n' +
            '      计量点数据 \n' +
            '    </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="" class="layui-form-label"> <span class="x-red">*</span>计量点设置</label> \n' +
            '      <div class="layui-input-inline">\n' +
            '        根据供电方式，确定对你单位共设置 \n' +
            '       <br /> \n' +
            '       <input type="hidden" class="meteringSpotCount" value="" /> \n' +
            '       <input type="radio" name="meteringSpotCount'+countDigit+'" lay-verify="otherReq" lay-filter="meteringSpotCount" value="1" title="一" /> \n' +
            '       <input type="radio" name="meteringSpotCount'+countDigit+'" lay-verify="otherReq" lay-filter="meteringSpotCount" value="2" title="二" /> \n' +
            '       <input type="radio" name="meteringSpotCount'+countDigit+'" lay-verify="otherReq" lay-filter="meteringSpotCount" value="3" title="三" /> \n' +
            '       <input type="radio" name="meteringSpotCount'+countDigit+'" lay-verify="otherReq" lay-filter="meteringSpotCount" value="4" title="四" /> \n' +
            '       <br />处计量点，安装 \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="InstallationLocation" class="layui-form-label"> <span class="x-red">*</span>安装位置 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="InstallationLocation" name="InstallationLocation" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="" class="layui-form-label"> <span class="x-red">*</span>数据通信方式 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="hidden" class="dataCommunicationWay" value="" /> \n' +
            '       <input type="radio" name="dataCommunicationWay'+countDigit+'"  lay-verify="otherReq" lay-filter="dataCommunicationWay" value="1" title="网络" /> \n' +
            '       <input type="radio" name="dataCommunicationWay'+countDigit+'"  lay-verify="otherReq" lay-filter="dataCommunicationWay" value="2" title="4G" /> \n' +
            '       <input type="radio" name="dataCommunicationWay'+countDigit+'"  lay-verify="otherReq" lay-filter="dataCommunicationWay" value="3" title="PSIN" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="meteringWay" class="layui-form-label"> <span class="x-red">*</span>计量方式 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="meteringWay" name="meteringWay" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="connectionMode" class="layui-form-label"> <span class="x-red">*</span>互感器接线方式 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="connectionMode" name="connectionMode" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="meteringSpotVoltage" class="layui-form-label"> <span class="x-red">*</span>计量点电压 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="meteringSpotVoltage" name="meteringSpotVoltage" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="" class="layui-form-label"> <span class="x-red">*</span>计量终端类型 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="hidden" class="terminalType" value="" /> \n' +
            '       <input type="radio" name="terminalType'+countDigit+'"  lay-verify="otherReq" lay-filter="terminalType" value="1" title="大客户" /> \n' +
            '       <input type="radio" name="terminalType'+countDigit+'"  lay-verify="otherReq" lay-filter="terminalType" value="2" title="变电站" /> \n' +
            '       <input type="radio" name="terminalType'+countDigit+'"  lay-verify="otherReq" lay-filter="terminalType" value="3" title="接入院采控系统" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="energyMeterType" class="layui-form-label"> <span class="x-red">*</span>电能表类别 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="energyMeterType" name="energyMeterType" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="energyMeterVoltage" class="layui-form-label"> <span class="x-red">*</span>电能表标称电压（V） </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="energyMeterVoltage" name="energyMeterVoltage" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="energyMeterElectric" class="layui-form-label"> <span class="x-red">*</span>电能表标称电流（A） </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="energyMeterElectric" name="energyMeterElectric" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="energyMeterAccuracy" class="layui-form-label"> <span class="x-red">*</span>电能表表计精度 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="energyMeterAccuracy" name="energyMeterAccuracy" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="voltageMutualInductorVoltage" class="layui-form-label"> <span class="x-red">*</span>电压互感器额定电压 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="voltageMutualInductorVoltage" name="voltageMutualInductorVoltage" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="voltageMutualInductorVariableRatio" class="layui-form-label"> <span class="x-red">*</span>电压互感器变比 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="voltageMutualInductorVariableRatio" name="voltageMutualInductorVariableRatio" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="voltageMutualInductorAccuracy" class="layui-form-label"> <span class="x-red">*</span>电压互感器精度 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="voltageMutualInductorAccuracy" name="voltageMutualInductorAccuracy" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="voltageMutualInductorCount" class="layui-form-label"> <span class="x-red">*</span>电压互感器台数 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="voltageMutualInductorCount" name="voltageMutualInductorCount" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="electricMutualInductorVoltage" class="layui-form-label"> <span class="x-red">*</span>电流互感器额定电压 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="electricMutualInductorVoltage" name="electricMutualInductorVoltage" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="electricMutualInductorVariableRatio" class="layui-form-label"> <span class="x-red">*</span>电流互感器变比 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="electricMutualInductorVariableRatio" name="electricMutualInductorVariableRatio" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="electricMutualInductorAccuracy" class="layui-form-label"> <span class="x-red">*</span>电流互感器精度 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="electricMutualInductorAccuracy" name="electricMutualInductorAccuracy" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="electricMutualInductorCount" class="layui-form-label"> <span class="x-red">*</span>电流互感器台数 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="electricMutualInductorCount" name="electricMutualInductorCount" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="meteringTerminalLocation" class="layui-form-label"> <span class="x-red">*</span>计量终端安装位置 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="meteringTerminalLocation" name="meteringTerminalLocation" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="meteringTerminalAccuracy" class="layui-form-label"> <span class="x-red">*</span>计量终端精度 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="meteringTerminalAccuracy" name="meteringTerminalAccuracy" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <label for="meteringTerminalCount" class="layui-form-label"> <span class="x-red">*</span>计量终端台数 </label> \n' +
            '      <div class="layui-input-inline"> \n' +
            '       <input type="text" id="meteringTerminalCount" name="meteringTerminalCount" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input" /> \n' +
            '      </div> \n' +
            '      <div class="layui-form-mid layui-word-aux"> \n' +
            '       <span class="x-red">*</span> \n' +
            '      </div> \n' +
            '     </div> \n' +
            '     <div class="layui-form-item"> \n' +
            '      <div class="layui-btn" type="button" onclick="powerSupply()">\n' +
            '        添加计量信息 \n' +
            '      </div> \n' +
            '      <div class="layui-btn" type="button" onclick="deleteTemp(this)">\n' +
            '        删除当前计量信息 \n' +
            '      </div> \n' +
            '     </div> \n' +
            '   </div> \n' +
            '  </div>  \n';
        $("#meteringList").append(html);
        countDigit++;
        renderForm();
    }


    function deleteTemp(o){
        $(o).parent().parent().parent().remove();
    }

    $(function(){
        getProTime($("#idxProAdmin").val(),20);

        var type = $("#paramsType").val();
        if(type === 'edit'){
            ajaxFunJson('POST','/pc/project/getPowerSupplySchemeInfo',JSON.stringify({"idProAdmin":$("#idxProAdmin").val()}),function(data){
                if(data.code != 0){
                    alertFun(data);
                }else{
                    var proPowerSupplySchemeMeteringList = data.data.proPowerSupplySchemeMeteringList;
                    var j=0;
                    for(var i=0;i<proPowerSupplySchemeMeteringList.length;i++){
                        powerSupply();
                        if(isNotNull(proPowerSupplySchemeMeteringList[i])) {
                            if (isNotNull(proPowerSupplySchemeMeteringList[i].dataCommunicationWay)) {
                                $(".layui-card").children(".layui-form-item").children(".layui-input-inline")
                                    .children("input[name=dataCommunicationWay" + (i + 1) + "][value=" + proPowerSupplySchemeMeteringList[i].dataCommunicationWay + "]").prop("checked", "true");
                            }
                            if (isNotNull(proPowerSupplySchemeMeteringList[i].meteringSpotCount)) {
                                $(".layui-card").children(".layui-form-item").children(".layui-input-inline")
                                    .children("input[name=meteringSpotCount" + (i + 1) + "][value=" + proPowerSupplySchemeMeteringList[i].meteringSpotCount + "]").prop("checked", "true");
                            }
                            if (isNotNull(proPowerSupplySchemeMeteringList[i].terminalType)) {
                                $(".layui-card").children(".layui-form-item").children(".layui-input-inline")
                                    .children("input[name=terminalType" + (i + 1) + "][value=" + proPowerSupplySchemeMeteringList[i].terminalType + "]").prop("checked", "true");
                            }
                            renderForm();
                        }
                    }
                    $(".layui-card").each(function(){
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].connectionMode)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=connectionMode]").val(proPowerSupplySchemeMeteringList[j].connectionMode);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].electricMutualInductorAccuracy)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=electricMutualInductorAccuracy]").val(proPowerSupplySchemeMeteringList[j].electricMutualInductorAccuracy);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].electricMutualInductorCount)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=electricMutualInductorCount]").val(proPowerSupplySchemeMeteringList[j].electricMutualInductorCount);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].electricMutualInductorVariableRatio)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=electricMutualInductorVariableRatio]").val(proPowerSupplySchemeMeteringList[j].electricMutualInductorVariableRatio);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].electricMutualInductorVoltage)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=electricMutualInductorVoltage]").val(proPowerSupplySchemeMeteringList[j].electricMutualInductorVoltage);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].energyMeterAccuracy)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=energyMeterAccuracy]").val(proPowerSupplySchemeMeteringList[j].energyMeterAccuracy);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].energyMeterElectric)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=energyMeterElectric]").val(proPowerSupplySchemeMeteringList[j].energyMeterElectric);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].energyMeterType)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=energyMeterType]").val(proPowerSupplySchemeMeteringList[j].energyMeterType);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].energyMeterVoltage)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=energyMeterVoltage]").val(proPowerSupplySchemeMeteringList[j].energyMeterVoltage);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].installationLocation)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=InstallationLocation]").val(proPowerSupplySchemeMeteringList[j].installationLocation);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].meteringSpotVoltage)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=meteringSpotVoltage]").val(proPowerSupplySchemeMeteringList[j].meteringSpotVoltage);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].meteringTerminalAccuracy)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=meteringTerminalAccuracy]").val(proPowerSupplySchemeMeteringList[j].meteringTerminalAccuracy);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].meteringTerminalCount)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=meteringTerminalCount]").val(proPowerSupplySchemeMeteringList[j].meteringTerminalCount);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].meteringTerminalLocation)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=meteringTerminalLocation]").val(proPowerSupplySchemeMeteringList[j].meteringTerminalLocation);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].meteringWay)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=meteringWay]").val(proPowerSupplySchemeMeteringList[j].meteringWay);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].voltageMutualInductorAccuracy)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=voltageMutualInductorAccuracy]").val(proPowerSupplySchemeMeteringList[j].voltageMutualInductorAccuracy);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].voltageMutualInductorCount)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=voltageMutualInductorCount]").val(proPowerSupplySchemeMeteringList[j].voltageMutualInductorCount);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].voltageMutualInductorVariableRatio)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=voltageMutualInductorVariableRatio]").val(proPowerSupplySchemeMeteringList[j].voltageMutualInductorVariableRatio);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].voltageMutualInductorVoltage)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=voltageMutualInductorVoltage]").val(proPowerSupplySchemeMeteringList[j].voltageMutualInductorVoltage);
                        }

                        if(isNotNull(proPowerSupplySchemeMeteringList[j].dataCommunicationWay)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline")
                                .children(".dataCommunicationWay").val(proPowerSupplySchemeMeteringList[j].dataCommunicationWay);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].meteringSpotCount)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline")
                                .children(".meteringSpotCount").val(proPowerSupplySchemeMeteringList[j].meteringSpotCount);
                        }
                        if(isNotNull(proPowerSupplySchemeMeteringList[j].terminalType)) {
                            $(this).children(".layui-form-item").children(".layui-input-inline")
                                .children(".terminalType").val(proPowerSupplySchemeMeteringList[j].terminalType);
                        }

                        j++;
                    })
                }
            })
        }else if(type === 'add'){
            powerSupply();
        }
    })

    layui.use(['form','layer'], function() {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer, layedit = layui.layedit;

        //自定义验证规则
        form.verify({
            otherReq: function(value,item){
                var $ = layui.$;
                var verifyName=$(item).attr('name')
                    , verifyType=$(item).attr('type')
                    ,formElem=$(item).parents('.layui-form')//获取当前所在的form元素，如果存在的话
                    ,verifyElem=formElem.find('input[name='+verifyName+']')//获取需要校验的元素
                    ,isTrue= verifyElem.is(':checked')//是否命中校验
                    ,focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
                if(!isTrue || !value) {
                    //定位焦点
                    focusElem.css(verifyType == 'radio' ? {"color": "#FF5722"} : {"border-color": "#FF5722"});
                    //对非输入框设置焦点
                    focusElem.first().attr("tabIndex", "1").css("outline", "0").blur(function () {
                        focusElem.css(verifyType == 'radio' ? {"color": ""} : {"border-color": ""});
                    }).focus();
                    return '必填项不能为空';
                }
            }
        });


        form.on('radio(meteringSpotCount)', function (data) {
            $(this).siblings(".meteringSpotCount").val(data.value);
        })
        form.on('radio(dataCommunicationWay)', function (data) {
            $(this).siblings(".dataCommunicationWay").val(data.value);
        })
        form.on('radio(terminalType)', function (data) {
            $(this).siblings(".terminalType").val(data.value);
        })

        //添加电源信息
        layui.$('#addPowerSupply').on('click', function(){
            powerSupply();
        });

        //添加电源信息
        layui.$('#addPowerSupply').on('click', function(){
            powerSupply();
        });

        //监听提交
        form.on('submit(add)', function (t) {
            addSubmit(3);
        });


    });

    function addSubmit(submitState){
        var myArray=new Array(),i = 0;
        $(".layui-card").each(function(){
            var data = {
                "connectionMode": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=connectionMode]").val(),
                "electricMutualInductorAccuracy": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=electricMutualInductorAccuracy]").val(),
                "electricMutualInductorCount": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=electricMutualInductorCount]").val(),
                "electricMutualInductorVariableRatio": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=electricMutualInductorVariableRatio]").val(),
                "electricMutualInductorVoltage": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=electricMutualInductorVoltage]").val(),
                "energyMeterAccuracy": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=energyMeterAccuracy]").val(),
                "energyMeterElectric": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=energyMeterElectric]").val(),
                "energyMeterType": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=energyMeterType]").val(),
                "energyMeterVoltage": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=energyMeterVoltage]").val(),
                "installationLocation": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=InstallationLocation]").val(),
                "meteringSpotVoltage": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=meteringSpotVoltage]").val(),
                "meteringTerminalAccuracy": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=meteringTerminalAccuracy]").val(),
                "meteringTerminalCount": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=meteringTerminalCount]").val(),
                "meteringTerminalLocation": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=meteringTerminalLocation]").val(),
                "meteringWay": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=meteringWay]").val(),
                "voltageMutualInductorAccuracy": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=voltageMutualInductorAccuracy]").val(),
                "voltageMutualInductorCount": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=voltageMutualInductorCount]").val(),
                "voltageMutualInductorVariableRatio": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=voltageMutualInductorVariableRatio]").val(),
                "voltageMutualInductorVoltage": $(this).children(".layui-form-item").children(".layui-input-inline").children("input[name=voltageMutualInductorVoltage]").val(),

                "dataCommunicationWay": $(this).children(".layui-form-item").children(".layui-input-inline")
                    .children(".dataCommunicationWay").val(),
                "meteringSpotCount": $(this).children(".layui-form-item").children(".layui-input-inline")
                    .children(".meteringSpotCount").val(),
                "terminalType": $(this).children(".layui-form-item").children(".layui-input-inline")
                    .children(".terminalType").val()
            }
            myArray[i] = data;
            i++
        })
        var params = {
            //tcaDescribe : layui.layedit.getContent(index),
            "idProAdmin": $("#idxProAdmin").val(),
            "idProPowerSupplyScheme":$("#idProPowerSupplyScheme").val(),
            "proPowerSupplySchemeMeteringList":myArray,
        }

        console.log(params);
        debugger
        if (true) {
            ajaxFunJson('post','/pc/project/updatePowerSupplyScheme',JSON.stringify(params),function(data){
                if (data.code != 0) {
                    alertFun(data);
                } else {
                    window.location.href = path + "/modules/project/onePro/zdgdfa/list.html";
                    console.log("success !");
                }
            })
            return false;
        }
    }
</script></body></html>